package com.hxzy.controller.front;

import com.hxzy.common.controller.BaseController;
import com.hxzy.common.enums.AckCode;
import com.hxzy.common.vo.R;
import com.hxzy.entity.Merchandise;
import com.hxzy.service.ProductService;
import com.hxzy.vo.ProductDishFlavorVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "前端商品API")
@RestController
@RequestMapping(value = "/front/dish")
public class FrontProductController extends BaseController {

    @Autowired
    private ProductService productService;


    @ApiOperation(value = "根据商家ID和分类的ID查询菜品列表")
    @GetMapping(value = "/list")
    public R findDishByCategory(Long categoryId,Long merchantId){

       if(categoryId==null || merchantId==null){
           return R.build(AckCode.SYSTEM_PARAM_FAIL);
       }

        List<ProductDishFlavorVO> arr=this.productService.searchByCategoryAndMerchant(categoryId,merchantId);
        return R.okHasData(arr);
    }
}
